# Column Layout

## Examples


### Columns and Spans

The span property can be set to vary the width of the Columns. The spans must add up to 12. The Columns are colored for this example.

```typescript
import React from 'react';

import ColumnLayout from '@splunk/react-ui/ColumnLayout';
import { useSplunkTheme } from '@splunk/themes';


function Basic() {
    const { syntaxBlue } = useSplunkTheme();
    const colStyle: React.CSSProperties = {
        border: `1px solid ${syntaxBlue}`,
        padding: 10,
        minHeight: 80,
    };

    return (
        <ColumnLayout>
            <ColumnLayout.Row>
                <ColumnLayout.Column style={colStyle}>1</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>2</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>3</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>4</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>5</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>6</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>7</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>8</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>9</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>10</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>11</ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle}>12</ColumnLayout.Column>
            </ColumnLayout.Row>
            <ColumnLayout.Row>
                <ColumnLayout.Column style={colStyle} span={4}>
                    Span 4
                </ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle} span={8}>
                    Span 8
                </ColumnLayout.Column>
            </ColumnLayout.Row>
            <ColumnLayout.Row>
                <ColumnLayout.Column style={colStyle} span={2}>
                    Span 2
                </ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle} span={5}>
                    Span 5
                </ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle} span={5}>
                    Span 5
                </ColumnLayout.Column>
            </ColumnLayout.Row>
            <ColumnLayout.Row>
                <ColumnLayout.Column style={colStyle} span={6}>
                    Span 6
                </ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle} span={3}>
                    Span 3
                </ColumnLayout.Column>
                <ColumnLayout.Column style={colStyle} span={3}>
                    Span 3
                </ColumnLayout.Column>
            </ColumnLayout.Row>
        </ColumnLayout>
    );
}

export default Basic;
```



### Gutters

Column Layout spaces Rows and Columns with gutters, but these can be removed or changed.

```typescript
import React from 'react';

import ColumnLayout from '@splunk/react-ui/ColumnLayout';
import Heading from '@splunk/react-ui/Heading';
import { useSplunkTheme } from '@splunk/themes';


function Gutters() {
    const { syntaxBlue } = useSplunkTheme();
    const colStyle: React.CSSProperties = {
        border: `1px solid ${syntaxBlue}`,
        padding: 10,
        minHeight: 80,
    };
    const headingStyle: React.CSSProperties = {
        margin: '1.414em 0 0.4em',
    };

    return (
        <div>
            <Heading level={4} style={headingStyle}>
                8px gutter
            </Heading>
            <ColumnLayout gutter={8}>
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        1 of 2
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        2 of 2
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        1 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
            </ColumnLayout>
            <Heading level={4} style={headingStyle}>
                0px gutter
            </Heading>
            <ColumnLayout gutter={0}>
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        1 of 2
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        2 of 2
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        1 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
            </ColumnLayout>
        </div>
    );
}

export default Gutters;
```



### Dividers

Column Layout can show different types of dividers.

```typescript
import React from 'react';

import ColumnLayout from '@splunk/react-ui/ColumnLayout';
import Heading from '@splunk/react-ui/Heading';
import { useSplunkTheme } from '@splunk/themes';


function Dividers() {
    const { syntaxBlue } = useSplunkTheme();
    const colStyle: React.CSSProperties = {
        border: `1px solid ${syntaxBlue}`,
        padding: 10,
        minHeight: 80,
    };
    const headingStyle: React.CSSProperties = {
        margin: '1.414em 0 0.4em',
    };

    return (
        <div>
            <Heading level={4} style={headingStyle}>
                Vertical dividers
            </Heading>
            <ColumnLayout divider="vertical">
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        1 of 2
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        2 of 2
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        1 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
            </ColumnLayout>
            <Heading level={4} style={headingStyle}>
                Horizontal dividers
            </Heading>
            <ColumnLayout divider="horizontal">
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        1 of 2
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={6} style={colStyle}>
                        2 of 2
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
                <ColumnLayout.Row>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        1 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                    <ColumnLayout.Column span={4} style={colStyle}>
                        2 of 3
                    </ColumnLayout.Column>
                </ColumnLayout.Row>
            </ColumnLayout>
        </div>
    );
}

export default Dividers;
```



### Align Items

By default, the Columns grow vertically to fill the available space. The values for this property are the same as flexbox's align-items property.

```typescript
import React from 'react';

import ColumnLayout from '@splunk/react-ui/ColumnLayout';
import { useSplunkTheme } from '@splunk/themes';


function AlignItems() {
    const { syntaxBlue } = useSplunkTheme();
    const colStyle: React.CSSProperties = { border: `1px solid ${syntaxBlue}`, padding: 10 };

    return (
        <ColumnLayout>
            <ColumnLayout.Row alignItems="stretch">
                <ColumnLayout.Column span={4} style={colStyle}>
                    A short column can stretch to fill the space.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    A tall
                    <br />
                    column defines
                    <br />
                    the height
                    <br />
                    of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    Another
                    <br />
                    column.
                </ColumnLayout.Column>
            </ColumnLayout.Row>
            <ColumnLayout.Row alignItems="start">
                <ColumnLayout.Column span={4} style={colStyle}>
                    A short column can align to the start (top) of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    A tall
                    <br />
                    column defines
                    <br />
                    the height
                    <br />
                    of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    Another
                    <br />
                    column.
                </ColumnLayout.Column>
            </ColumnLayout.Row>
            <ColumnLayout.Row alignItems="end">
                <ColumnLayout.Column span={4} style={colStyle}>
                    A short column can align to the end (bottom) of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    A tall
                    <br />
                    column defines
                    <br />
                    the height
                    <br />
                    of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    Another
                    <br />
                    column.
                </ColumnLayout.Column>
            </ColumnLayout.Row>
            <ColumnLayout.Row alignItems="center">
                <ColumnLayout.Column span={4} style={colStyle}>
                    A short column can align to the center (middle) of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    A tall
                    <br />
                    column defines
                    <br />
                    the height
                    <br />
                    of the row.
                </ColumnLayout.Column>
                <ColumnLayout.Column span={4} style={colStyle}>
                    Another
                    <br />
                    column.
                </ColumnLayout.Column>
            </ColumnLayout.Row>
        </ColumnLayout>
    );
}

export default AlignItems;
```




## API


### ColumnLayout API

@deprecated
ColumnLayout has been deprecated and will be removed in a future major version. Use CSS `grid` or `flex` instead.

#### Props

| Name | Type | Required | Default | Description |
|------|------|------|------|------|
| children | React.ReactNode | no |  | `children` must be `ColumnLayout.Row` elements. |
| divider | 'none' \| 'vertical' \| 'horizontal' | no | 'none' | Show dividers between columns. |
| elementRef | React.Ref<HTMLDivElement> | no |  | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
| gutter | number | no |  | Set gutter width in pixels. This is propagated down to its `children`. |



### ColumnLayout.Row API

#### Props

| Name | Type | Required | Default | Description |
|------|------|------|------|------|
| alignItems | 'start' \| 'end' \| 'center' \| 'stretch' | no | 'stretch' | Set vertical alignment of columns in a row |
| children | React.ReactNode | no |  | `children` must be `ColumnLayout.Column` elements |
| elementRef | React.Ref<HTMLDivElement> | no |  | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |



### ColumnLayout.Column API

#### Props

| Name | Type | Required | Default | Description |
|------|------|------|------|------|
| children | React.ReactNode | no |  |  |
| elementRef | React.Ref<HTMLDivElement> | no |  | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
| span | number | no | 1 | The number of columns the element spans. |





